Repository navigation
fix(fleet): recorded tailnet proxy beats ambient env in the Python client and broker - #13071
Merged
Merged
Conversation
…ient and broker For #12426 (the Python-side remainder of the #12555 failure class). The Rust broker learned this rule in #12645: fleet-config's tailnet_https_proxy resolves the seat's recorded fleet-proxy.env ahead of the ambient HTTPS_PROXY for tailnet tunnels. The Python paths still read only the ambient env, so a Python client or broker (re)started from a sandbox shell inherited the platform egress proxy and every tailnet CONNECT failed while the process looked alive. laptop-agent.py gains the mirror resolver — candidate order ($FLEET_PROXY_ENV, then the named agent's ~/.local/state/tailscale/agents/<slug>/fleet-proxy.env, then ~/.local/state/tailscale/fleet-proxy.env), the bootstrap slug rule, and the env-file parse rule all match fleet-config's — and tunnel_socket prefers it for the tailnet leg. The Cloudflare leg keeps the ambient proxy, as in the Rust shape. The broker's broker_tunnel_socket resolves through the client's resolver when the deployed copy provides one. Tests: pkgs/fleet/tests/test_tailnet_proxy_env.py, 9 cases mirroring fleet-config's slug/candidate/parse cases plus resolution order and an end-to-end tunnel_socket preference check against a fake CONNECT proxy. Run: python3 -m unittest discover -s pkgs/fleet/tests — OK.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #12426 — the Python-side remainder of the #12555 failure class (auto-spawned broker inherits the caller's ambient proxy env and silently breaks tailnet tunnels).
What
The Rust broker learned the durable rule in #12645:
fleet_config::tailnet_https_proxy()resolves the seat's recordedfleet-proxy.envahead of the ambientHTTPS_PROXYfor tailnet tunnels. The Python paths still read only the ambient env:tunnel_socketinpkgs/fleet/laptop-agent.pybroker_tunnel_socketinpkgs/fleet/laptop-agent-broker.pyso a Python client/broker (re)started from a sandbox shell still inherited the platform egress proxy and broke the queue/shell legs exactly as filed in #12426 — while the bootstrap's own comment ("Fleet's tailnet tunnels prefer this file over the ambient proxy") claimed otherwise.
This PR mirrors the rule in Python:
laptop-agent.pygainstailnet_https_proxy()with fleet-config's exact candidate order ($FLEET_PROXY_ENV, then the named agent's~/.local/state/tailscale/agents/<slug>/fleet-proxy.env, then~/.local/state/tailscale/fleet-proxy.env), bootstrap slug rule, and env-file parse rule;tunnel_socketprefers the recorded proxy for the tailnet leg.Verification
New
pkgs/fleet/tests/test_tailnet_proxy_env.py— 9 tests, all passing (python3 -m unittest discover -s pkgs/fleet/tests): the slug/candidate/parse cases mirror fleet-config's Rust cases value-for-value; resolution-order tests cover shared < agent < explicit; an end-to-endtunnel_sockettest against a fake CONNECT proxy proves the recorded proxy wins over an ambient egress proxy and the ambient proxy is used when no file exists. Both edited files compile clean (py_compile).Scope note
#12426 stays open: the out-of-repo spawn sites it names (the sandbox ensure layer) now have nothing left to police for correctness — both broker implementations self-correct at CONNECT time — but retiring or re-pointing that watchdog is a primary-seat call, and #12555 remains the parent record of the failure class.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.